<?php

class Core_Backend_Component_Customer_View_Index_Index extends Core_Backend_Share_View_Grid {

    protected function buildGrid($grid) {
        $filter = new Kd_Object($this->getRequest()->getParameter('filter'));
        $grid->setId('shop_grid')
                ->setPrimaryKey('id')
                ->setAllowFilter(TRUE)
                ->setSortField($this->getRequest()->getParameter('sort', 'id'))
                ->setSortDirection($this->getRequest()->getParameter('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl());
        $grid->addLabelColumn($this->__('poi.label.poi_id'), 'id', '{id}')
                ->setTextboxFilter(NULL, NULL, $filter->getData('id'))
                ->setSortField('id')
                ->setWidth(140);
        $grid->addLabelColumn($this->__('poi.label.shop_name'), 'shopname', '{shop_name}')
        		->setTextboxFilter(NULL, NULL, $filter->getData('id'))
                ->setSortField('shop_name');
//        $grid->addLabelColumn($this->__('poi.label.industry'), 'industryname', '{industry_{industry_id}}')
//                ->setSortField('industry_name')
//                ->setWidth(80)
//                ->setAlign('center');
//        $grid->addLabelColumn($this->__('poi.label.address'), 'address', '{address}');
//        $grid->addLabelColumn($this->__('poi.label.business_phone'), 'business_phone', '{business_phone}')
//                ->setWidth(100);
//        $grid->addLabelColumn($this->__('poi.label.mobile'), 'mobile', '{mobile}')
//                ->setWidth(100);
		if($this->getIdentity()->isAllowAction('customer_showroom_read')){
	        $grid->addLinkColumn($this->__('customer.label.showroom'), 'showroom', $this->getUrl(array('poiid' => '{id}'), 'index', 'showroom'), $this->__('share.button.edit'))
	                ->setWidth(70)
	                ->setAlign('center');
		}
        $grid->addLinkColumn($this->__('customer.label.map'), 'map_status', $this->getUrl(array('poiid' => '{id}'), 'edit', 'map'), $this->__('share.button.edit'))
                ->setWidth(70)
                ->setAlign('center');
        $grid->addLinkColumn($this->__('customer.label.shop'), 'shop_status', $this->getUrl(array('poiid' => '{id}'), 'edit', 'shop'), $this->__('share.button.edit'))
                ->setWidth(70)
                ->setAlign('center');
        $grid->addLinkColumn($this->__('customer.label.product'), 'product', $this->getUrl(array('poiid' => '{id}'), 'index', 'product'), $this->__('share.button.edit'))
                ->setWidth(50)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $url = $this->getPaginationUrl();
        $pagination->setUrlFormat($url)->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }

}